package com.woniuxy.tfss.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.woniuxy.tfss.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderMapper extends BaseMapper<Order> {

    @Select("select * from tfss_order where no=#{no}")
    public Order getByNo(String no);

    @Select("select o.*,r.phonenum as riderphone from tfss_order o left join tfss_rider r on o.riderid=r.id where o.userid=#{userId}")
    public List<Order> getByUserId(Integer userId);

    @Select("select * from tfss_order where riderid=#{riderId} and status=#{status}")
    public List<Order> getByRiderId(Integer riderId, String status);

    @Select("select * from tfss_order where userid=#{userId} and DATE(ordertime) = CURDATE()")
    List<Order> getTodayOrder(Integer userId);

    @Select("select * from tfss_order where riderid=#{riderId} and DATE(ordertime) = CURDATE() and (status='4' or status='5' or status='6' or status='8' or status='14' or status='15'")
    List<Order> getRiderTodayOrder(Integer riderId);

    @Select("select * from tfss_order where userid=#{userId} and status=#{status}")
    List<Order> getByStatus(Integer userId, String status);

    @Select("select * from tfss_order where status='7'")
    List<Order> getWaitConfirmOrder();

    @Select("select * from tfss_order where status='1' and riderid is null")
    List<Order> getWaitRiderOrder();

    @Select("select * from tfss_order where status='2'")
    List<Order> getRidingOrder();

    @Select("SELECT * FROM tfss_order WHERE STATUS='1' AND DATE_ADD(arrangetime,INTERVAL -30 MINUTE) < CURTIME()")
    List<Order> getCanRobOrder();

}
